﻿using System;
using System.Web;

namespace Xpus.Web.Common
{
	/// <summary>
	/// 用于处理xpus请求的HTTP模块。
	/// </summary>
	public class XpusModule : IHttpModule
	{
		#region IHttpModule Members
		/// <summary>
		/// 释放当前模块占用的资源（不是内存）。
		/// </summary>
		public void Dispose()
		{
		}

		/// <summary>
		/// 初始化。
		/// </summary>
		/// <param name="context">请求的上下文。</param>
		public void Init(HttpApplication context)
		{
			context.BeginRequest += delegate(object sender, EventArgs e)
			{
				XpusContext.CreateContext();
			};

			context.AuthorizeRequest += delegate(object sender, EventArgs e)
			{
				XpusContext.RewriteUrl((HttpApplication)sender);
			};
		}
		#endregion
	}
}
